const uuidv1 = require('uuid/v1');
var mqtt = require('mqtt')

const uuid = uuidv1();
const socket_url = 'mqtt://localhost:1883'

const options = {
  username: 'guest',
  password: 'oneguestctp',
  clientId: uuid,
  protocolId: 'MQTT',
  protocolVersion: 4,
  reconnectPeriod: 30000,
  connectTimeout: 30000,
  clean: true,
  keepalive: 120,
}

const client = mqtt.connect(socket_url)

let item = {
    t: new Date().getTime(),
    highPrice: 0.9,
    lowPrice: 0.2,
    openPrice: 0.8,
    closePrice: 0.5,
    volume: 20,
    resolution: 1,
    type: 1,
    currencyRelation: 'ccccc'
}

setInterval(()=>{
    client.publish('mqtt-test', JSON.stringify(item))
},2000)